// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
// import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;

// import java.util.Arrays;
// import java.util.List;

#include "OracleTreatExpr.h"
#include "../../../../ast/SQLObject.h"
#include "../../visitor/OracleASTVisitor.h"

SQLExpr_ptr OracleTreatExpr::getExpr()
{
  return expr;
}

void OracleTreatExpr::setExpr(SQLExpr_ptr expr)
{
  if (expr != nullptr)
  {
    expr->setParent(SharedObject(OracleTreatExpr));
  }
  this->expr = expr;
}

SQLExpr_ptr OracleTreatExpr::getType()
{
  return type;
}

void OracleTreatExpr::setType(SQLExpr_ptr type)
{
  if (type != nullptr)
  {
    type->setParent(SharedObject(OracleTreatExpr));
  }
  this->type = type;
}

BOOL_ptr OracleTreatExpr::isRef()
{
  return ref;
}

void OracleTreatExpr::setRef(BOOL_ptr ref)
{
  this->ref = ref;
}

// @Override
void OracleTreatExpr::accept0(OracleASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(OracleTreatExpr)))
  {
    acceptChild(visitor, expr);
    acceptChild(visitor, type);
  }
  visitor->endVisit(SharedObject(OracleTreatExpr));
}

SQLObject_list_ptr OracleTreatExpr::getChildren()
{
  SQLObject_list_ptr tmp = std::make_shared<std::list<SQLObject_ptr>>();
  tmp->push_back(this->expr);
  tmp->push_back(this->type);
  return tmp;
}

SQLObject_ptr OracleTreatExpr::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<OracleTreatExpr>(new OracleTreatExpr());
  std::shared_ptr<OracleTreatExpr> x = std::dynamic_pointer_cast<OracleTreatExpr>(clone_tmp);
  // OracleTreatExpr x = new OracleTreatExpr();

  if (expr != nullptr)
  {
    x->setExpr(std::dynamic_pointer_cast<SQLExpr>(expr->clone()));
  }

  if (type != nullptr)
  {
    x->setType(std::dynamic_pointer_cast<SQLExpr>(type->clone()));
  }

  x->ref = ref;

  return x;
}
